﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta name="format-detection" content="telephone=no" />
    <title>登录</title>
    <link rel="stylesheet" href="css/style.css?v=1.0">
    <link rel="stylesheet" href="css/index.css?v=1.0">
    <script src="js/jquery-1.8.3.min.js"></script>
    <script src="js/flexible.js?v=1.0"></script>
    <script src="layer-mobile/layer.js?v=1.0"></script>
</head>
<body>
    <div class="login">
        <div class="login-body">

            <p class="d-title">得币</p>
            <div class="login-btn">
                <input id="txtUserName" type="number" placeholder="请输入手机号" />
            </div>
            <div class="login-btn">
                <input id="txtValationCode" type="number" placeholder="验证码" />
                <input id="btnGetCode" type="button" value="获取验证码" class="fr login-code" />
            </div>
            <div class="login-regsion">
                <input id="btnLogin" type="button" value="登录" />
                <a href="/register.html">没有账号，去注册</a>
            </div>
        </div>
            
    </div>
  
</body>

</html>
<script>
    $(document).ready(function () {

        var _height = $(document).height();
        $('.login').css('height', _height);

        $('#txtUserName').focus();
        $("#btnLogin").click(function () {

            $.ajax({
                type: "POST",
                url: "/API/AjaxHandler.ashx?Action=KongtouWeb.UserAjax.UserLogin",
                data: {
                    userName: $("#txtUserName").val(),
                    valationCode: $("#txtValationCode").val()
                },
                async: false,
                error: function (request) {
                    layer.open({
                        content: '系统异常',
                        skin: 'msg',
                        time: 2
                    });
                },
                success: function (data) {
                    if (data.status == "1") {
                        localStorage.setItem("ktUserID", data.message);
                        location.href = "/index.html";
                    }
                    else {
                        layer.open({
                            content: data.message,
                            skin: 'msg',
                            time: 2
                        });
                    }

                }
            });
        })

        $("#btnGetCode").click(function () {

            $.ajax({
                type: "POST",
                url: "/API/AjaxHandler.ashx?Action=KongtouWeb.UserAjax.GetVerificationCode",
                data: {
                    mobile: $("#txtUserName").val(),
                    type: 2
                },
                async: false,
                error: function (request) {
                    layer.open({
                        content: '系统异常',
                        skin: 'msg',
                        time: 2
                    });
                },
                success: function (data) {
                    if (data.status == "1") {
                        
                        layer.open({
                            content: '验证码发送成功',
                            skin: 'msg',
                            time: 2
                        });
                    }
                    else {
                        layer.open({
                            content: data.message,
                            skin: 'msg',
                            time: 2
                        });
                    }

                }
            });

        });

    });
</script>